package com.aqielife.demo.router;

import com.aqielife.demo.service.CityService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * @author aqie
 * @date 2022/02/05 12:45
 * @desc
 */
@Configuration
public class CityRouter {
  @Bean
  public RouterFunction<ServerResponse> routeCity(@Qualifier("cityServiceMongoImpl") CityService cityHandler) {
    return RouterFunctions
    .route(RequestPredicates.GET("/city/hello")
    .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
    cityHandler::helloCity);
  }
}
